from django.db import models

# Create your models here.
class Student(models.Model):
    CHOICE_GENDER=(
        ('1','男'),
        ('2','女'),
    )
    id = models.IntegerField(primary_key=True)
    image = models.ImageField(upload_to='images/student/',null=True,blank=True)
    name = models.CharField(max_length=100)
    age = models.IntegerField()
    gender = models.CharField(choices=CHOICE_GENDER,max_length=10)
    department = models.CharField(max_length=100,verbose_name='系别')

    class Meta:
        db_table = 'student'

    def __str__(self):
        return self.name


class User(models.Model):
    image = models.ImageField(upload_to='images/user/',null=True,blank=True)
    username = models.CharField(max_length=100)
    password = models.CharField(max_length=100)
    email = models.EmailField(null=True,blank=True)

    def __str__(self):
        return self.username


class Grade(models.Model):
    student = models.ForeignKey(Student,on_delete=models.CASCADE)
    course = models.ForeignKey("Course",on_delete=models.CASCADE)
    grade = models.IntegerField()


class Course(models.Model):
    course_id = models.IntegerField(primary_key=True)
    course_name = models.CharField(max_length=100)
    create_user = models.ForeignKey(User,on_delete=models.CASCADE)
